package com.qf.controller;

import com.qf.pojo.AliyunProperties;
import com.qf.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @author YuGan
 */
@Controller
@RequestMapping("/sayhello")
public class TestController {

    /*第一种加载自定义配置信息方式*/
    @Value("${aliyun.username}")
    String username;
    @Value("${aliyun.ip}")
    String ip;
    /*第二种加载自定义配置信息方式*/
    @Autowired
    Environment environment;
    /*第三种加载自定义配置信息方式封装成AliyunProperties对象*/

    @Autowired
    private AliyunProperties aliyunProperties;
    public void testYml(){
        System.out.println("aliyun的username and ip:"+username+ip);
        System.out.println("aliyun的username and ip:"+environment.getProperty("aliyun.username")+environment.getProperty("aliyun.ip"));
        System.out.println("aliyun的username and ip:"+aliyunProperties.getUsername()+aliyunProperties.getIp());
    }



    @Autowired
    User user;
    @GetMapping("/test")
    public String test(){
        return "forward:aaa.html";
    }


}